import 'dart:math';
import 'package:flutter/material.dart';
import 'package:random_color/random_color.dart';

var priorityColor = [Colors.red, Colors.orange, Colors.yellow, Colors.white];

class ColorPalette {
  final String colorName;
  final int colorValue;

  ColorPalette(this.colorName, this.colorValue);
}

class RandomColorGen {
  static final Random _random = new Random();
  static final RandomColor _randomColor = RandomColor();

  /// Returns a random color.
  static Color next() {
    return new Color(0xFF000000 + _random.nextInt(0x00FFFFFF));
  }

  static Color nextColor() {
    return _randomColor.randomColor(colorBrightness: ColorBrightness.light);
  }

  static Color nextColorDark() {
    return _randomColor.randomColor(colorBrightness: ColorBrightness.dark);
  }

  static ColorPalette nextPalette() {
    return new ColorPalette("random",
        _randomColor.randomColor(colorBrightness: ColorBrightness.light).value);
  }
}

var colorsPalettes = <ColorPalette>[
  ColorPalette("Red", 0xffffa190),
  ColorPalette("Pink", Colors.pink.value),
  ColorPalette("Purple", Colors.purple.value),
  ColorPalette("Deep Purple", Colors.deepPurple.value),
  ColorPalette("Indigo", Colors.indigo.value),
  ColorPalette("Blue", Colors.blue.value),
  ColorPalette("Lightblue", Colors.lightBlue.value),
  ColorPalette("Cyan", Colors.cyan.value),
  ColorPalette("Teal", Colors.teal.value),
  ColorPalette("Green", Colors.green.value),
  ColorPalette("Lightgreen", Colors.lightGreen.value),
  ColorPalette("Lime", Colors.lime.value),
  ColorPalette("Yellow", Colors.yellow.value),
  ColorPalette("Amber", Colors.amber.value),
  ColorPalette("Orange", 0xffffa95f),
  ColorPalette("Deeporange", Colors.deepOrange.value),
  ColorPalette("Brown", Colors.brown.value),
  // ColorPalette("Black", Colors.black.value),
  ColorPalette("WindRed", 0xffffa190),
  ColorPalette("WindRedLight", 0xffffeeee),
  ColorPalette("WindGreen", 0xff61d2a1),
  ColorPalette("WindGreenLight", 0xff9df3c4),
  ColorPalette("White", 0xffffffff),
];

var colorsPalettesLight = <ColorPalette>[
  ColorPalette(
    "白色",
    Colors.pink.value,
  ),
  ColorPalette(
    "淡粉色",
    Color(0xFFF28C82).value,
  ),
  ColorPalette(
    "橙色",
    Color(0xFFFABD03).value,
  ),
  ColorPalette(
    "淡黄色",
    Color(0xFFFFF476).value,
  ),
  ColorPalette(
    "浅黄色",
    Color(0xFFCDFF90).value,
  ),
  ColorPalette(
    "淡蓝色",
    Color(0xFFA7FEEB).value,
  ),
  ColorPalette(
    "白蓝色",
    Color(0xFFCBF0F8).value,
  ),
  ColorPalette(
    "云蓝",
    Color(0xFFAFCBFA).value,
  ),
  ColorPalette(
    "淡紫色",
    Color(0xFFD7AEFC).value,
  ),
  ColorPalette(
    "Red",
    Color(0xFFFDCFE9).value,
  ),
  ColorPalette(
    "淡红色",
    Color(0xFFE6C9A9).value,
  ),
  ColorPalette(
    "淡白色",
    Color(0xFFE9EAEE).value,
  ),
  ColorPalette("Red", 0xffffa190),
  ColorPalette("Pink", Colors.pink.value),
  ColorPalette("Purple", Colors.purple.value),
  ColorPalette("Deep Purple", Colors.deepPurple.value),
  ColorPalette("Indigo", Colors.indigo.value),
  ColorPalette("Blue", Colors.blue.value),
  ColorPalette("Lightblue", Colors.lightBlue.value),
  ColorPalette("Cyan", Colors.cyan.value),
  ColorPalette("Teal", Colors.teal.value),
  ColorPalette("Green", Colors.green.value),
  ColorPalette("Lightgreen", Colors.lightGreen.value),
  ColorPalette("Lime", Colors.lime.value),
  ColorPalette("Yellow", Colors.yellow.value),
  ColorPalette("Amber", Colors.amber.value),
  ColorPalette("Orange", 0xffffa95f),
  ColorPalette("Deeporange", Colors.deepOrange.value),
  ColorPalette("Brown", Colors.brown.value),
  // ColorPalette("Black", Colors.black.value),
  ColorPalette("WindRed", 0xffffa190),
  ColorPalette("WindRedLight", 0xffffeeee),
  ColorPalette("WindGreen", 0xff61d2a1),
  ColorPalette("WindGreenLight", 0xff9df3c4),
  ColorPalette("White", 0xffffffff),
];

class ColorBook {
  static final Color red = Color(0xffffa190);
  static final Color redDeep = Color(0xffd90000);
  static final Color redDeepLighter = Color(0xffe64d27);
  static final Color lightGreen = Color(0xff9df3c4);
  static final Color green = Color(0xff61d2a1);
  static final Color lightRed = Color(0xffffeeee);

  static final Color yellowVIPLight = Color(0xffEDCC99);
  static final Color yellowVIP = Color(0xffE5BE81);

  static final Color yellowLight = Color(0xffe0c85e);
  static final Color yellowLightPlus = Color(0xffe8d066);

  static final Color brownVIPLight = Color(0xffEDCC99);
  static final Color brownVIP = Color(0xff634f17);

  static final Color orangeVIPLight = Color(0xffff8e59);
  static final Color orangeVIP = Color(0xffff8a1c);
  static final Color pink = Color(0xffec407a);
  static final Color greenMaerDai = Color(0xff009c8f);
  static final Color redGugong = Color(0xffba1436);
  static final Color orangeEnergy = Color(0xffff6836);
  static final Color blueNavy = Color(0xff443f69);
  static final Color greenYandai = Color(0xff295c49);
  static final Color blueShanhu = Color(0xff2b9ecc);
  static final Color deepBlue = Color(0xff2a43fa);
  static final Color purpleNight = Color(0xff9415b0);
  static final Color greyNapolun = Color(0xff303030);
  static final Color black = Color(0xff000000);

  // 玫瑰灰
  static final Color Redmeiguihui = Color(0xff4b2e2b);
  // 鹅血石红
  static final Color Redexueshi = Color(0xffab372f);
  // 淡栗综
  static final Color Browndanli = Color(0xff673424);
  // 珠母灰
  static final Color GreyZhumu = Color(0xff64483d);
  // 鹦鹉绿
  static final Color GreenYingwu = Color(0xff5bae23);
  // 荷叶绿
  static final Color GreenHeye = Color(0xff1a6840);
  // 秋波蓝
  static final Color Blueqiubo = Color(0xff8abcd1);

  static final Color lightBrown = Color(0xffCC9999);
  static final Color blueGrey = Color(0xff666699);
  static final Color lightPink = Color(0xffFF6666);
  static final Color lightPurple = Color(0xff993399);
  static final Color softPurple = Color(0xff9999CC);

  static final Color glassColor = Color(0x55EEE5E9);
    static Color borderColor = Color(0xFFFFFFFF);

}

// ranges from 0.0 to 1.0

Color darken(Color color, [double amount = .1]) {
  assert(amount >= 0 && amount <= 1);
  final hsl = HSLColor.fromColor(color);
  final hslDark = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0));

  return hslDark.toColor();
}

Color lighten(Color color, [double amount = .1]) {
  assert(amount >= 0 && amount <= 1);
  final hsl = HSLColor.fromColor(color);
  final hslLight = hsl.withLightness((hsl.lightness + amount).clamp(0.0, 1.0));
  return hslLight.toColor();
}
